﻿//======================================================================
//
//        Copyright (C) 2008 HOHO``
//        All rights reserved
//
//        filename :$safeitemrootname$
//        description :管理员操作，控制面板。
//
//        created by 裘中杰 at  $time$
//======================================================================


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Hisun.Models;
using Hisun.Controllers;

namespace Hisun.View.Admin
{
    public partial class AccountControlPanel : AbcPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["operatorID"] == null)
                Response.Redirect("~/default.aspx");
            AuthsToUser1.UserID = Request.QueryString["operatorID"];
            RolesToUser1.UserID = Request.QueryString["operatorID"];
        }

        protected void lnkBtnResetPassword_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtPassword.Text))
            {
                AbcAccount abcAccount = new AbcAccount(Session[ServerVars.sysSessionUserName].ToString());
                if (abcAccount.ResetPassword(Request.QueryString["operatorID"].ToString(), txtPassword.Text) != 0)
                {
                    throw new Exception(abcAccount.LastError);
                }
                Response.Write("Reset Password OK!");
            }
        }

        protected void lnkBtnDisableAccount_Click(object sender, EventArgs e)
        {
            AbcAccount abcAccount = new AbcAccount(Session[ServerVars.sysSessionUserName].ToString());
            if (abcAccount.SetEnable(Request.QueryString["operatorID"].ToString(),false) != 0)
            {
                throw new Exception(abcAccount.LastError);
            }
            Response.Write("Disabled!");
        }

        protected void lnkBtnEnableAccount_Click(object sender, EventArgs e)
        {
            AbcAccount abcAccount = new AbcAccount(Session[ServerVars.sysSessionUserName].ToString());
            if (abcAccount.SetEnable(Request.QueryString["operatorID"].ToString(), true) != 0)
            {
                throw new Exception(abcAccount.LastError);
            }
            Response.Write("Disabled!");
        }
    }
}
